<?php

	include("common.php");
	
	$result = mysql_query("SELECT * FROM `197_guestbook` ORDER BY `guestbook_id` DESC");
	$guestbook = array();
	while($row = mysql_fetch_assoc($result)){
		array_push($guestbook, $row);
	}

?>
<?php include("header.php"); ?>
<script type="text/javascript" defer="defer">
	function content(i, t){
		var target = $("#content-" + i);
		if(target.css("display") == "none"){
			target.slideDown("fast");
			t.innerHTML = "-";
		} else {
			target.slideUp("fast");
			t.innerHTML = "+";
		}
	}
</script>
<h1>197留言板</h1>
<p><a href="guestbookAdd.php">張貼留言</a></p>
<?php foreach($guestbook as $row){ ?>
	<div style="background: #EEE; border: 1px #CCC solid; padding-left: 10px; width: 400px; margin: 10px; padding-bottom: 10px;">
		<h3><?php echo $row['title']; ?> - [ <a href="javascript:void(0)" onclick="content('<?php echo $row['guestbook_id']; ?>', this);">+</a> ]</h3>
		<div style="padding-left: 10px; display: none" id="content-<?php echo $row['guestbook_id']; ?>">
			<?php echo $row['content']; ?>
			<p>由 <?php echo $row['name']; ?> 於 <?php echo $row['post_date']; ?> 張貼 - [ <a href="guestbookAdd.php?guestbook_id=<?php echo $row['guestbook_id']; ?>">引用</a> ]</p>
		</div>
	</div>
<?php } ?>
<?php include("sidebar.php"); ?>
<?php include("footer.php"); ?>